<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点击按钮切换图片</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="change">
    <p>
        <span><img :src="img1" v-if="imgSrc" width="200"></span>
        <span><img :src="img2" v-if="!imgSrc" width="220"></span>
    </p>
    <input type="button" value="点我切换图片" @click="click()">
    </div>

    <script>
        var vm = new Vue({
            el:"#change",
            data(){
                return{
                    img1:'img/1.jpg',
                    img2:'img/2.jpg',
                    imgSrc:true
                }
            },
            methods:{
                click(){
                    this.imgSrc = !this.imgSrc
                }
            }
        })
    </script>
</body>
</html>